﻿using CoachingOrganizer.Logic.Common;
using CoachingOrganizer.Logic.Models.Tools.MoneyCalculation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoachingOrganizer.Logic.Logic.Tools.MoneyCalculation
{
    internal class PeriodOccasionalGroupReportLogic : PeriodGroupReportLogicBase
    {
        private readonly PeriodOccasionalGroupReportModel _model;

        public PeriodOccasionalGroupReportModel Model
        {
            get { return _model; }
        }

        public PeriodOccasionalGroupReportLogic(PeriodOccasionalGroupReportModel model, LogicExtender logicExtender, PeriodReportLogic upperLogic)
            : base(model, logicExtender, upperLogic)
        {
            _model = model;
        }

        public PeriodOccasionalGroupReportLogic(string name, int sign, IEnumerable<OccasionalMoneyFlowItemLogic> items, LogicExtender logicExtender, PeriodReportLogic upperLogic)
            : this(new PeriodOccasionalGroupReportModel(name, sign, items.Select(l => l.Model)), logicExtender, upperLogic)
        {

        }

        public override decimal GetAmount()
        {
            return _model.Items.Select(i => i.Amount).Sum();
        }
    }
}
